package org.example.spring_principle.config;

import org.example.spring_principle.model.Dog;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class DogConfig {
    @Bean
    public Dog dog(){
        Dog dog=new Dog();
        dog.setName("旺旺");
        return dog;
    }
    @Bean
//    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    @Scope("singleton")
    public Dog singleDog(){
        return new Dog();
    }

    @Bean
//    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    @Scope("prototype")
    public Dog prototypeDog(){
        return new Dog();
    }
    @Bean
    @RequestScope
    public Dog requsetDog(){
        return new Dog();
    }
    @Bean
    @SessionScope
    public Dog sessionDog(){
        return new Dog();
    }
    @Bean
    @ApplicationScope
    public Dog applicationDog(){
        return new Dog();
    }
}
